package trab3.time;

public class SequencerClock2 extends Clock {
	static int value ;
	
	public SequencerClock2() {
		value = 0 ;
	}
	
	public String name() {
		return "SQ2" ;
	}
	
	public TimeStamp value() {
		return new TS( value ) ;
	}
	
	public Clock increment() {
		value += 1 ;
		return this ;
	}
	
	public Clock update( TimeStamp other ) {
		return this ;
	}
	
	
	@SuppressWarnings("serial")
	static class TS implements TimeStamp {
		final int value ;
		
		TS( int v ) {
			value = v ;
		}
		
		public int compareTo( TimeStamp other) {
			return compareTo( (TS) other ) ;
		}

		private int compareTo( TS other) {
			return value < other.value ? -1 : 1 ;
		}

		public boolean concurrent(TimeStamp other) {
			return concurrent((TS) other );
		}

		private  boolean concurrent(TS other) {
			return value == other.value ;
		}

		public String toString() {
			return "" + value ;
		}
	}
}